import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

/**
 * @author gao
 * @date 2025/8/16 15:27
 */

public class DictServer extends EchoServer {

    private HashMap<String, String> dict = new HashMap<>();
    public DictServer(int port) throws SocketException {
        super(port);

        dict.put("apple", "苹果");
        dict.put("banana", "香蕉");
        dict.put("dog", "小狗");
        dict.put("cat", "小猫");
        dict.put("browser", "浏览器");
    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request, "该单词没有查到");
    }

    public static void main(String[] args) throws IOException {
        DictServer dictServer = new DictServer(9090);
        dictServer.start();
    }
}